import featureAbility from '@ohos.ability.featureAbility'
import dataStorage from '@ohos.data.storage'

export default {
    onCreate() {
        console.info('AceApplication onCreate');
        this.getToken();
        //判断是否是第一次打开应用
    },
    onDestroy() {
        console.info('AceApplication onDestroy');
    },

    getToken() {
        featureAbility.getContext().getFilesDir().then((path) => {
            this.globalData.path = path + '/edu';
            console.info('File directory obtained. Data:' + this.globalData.path);
            let storage = dataStorage.getStorageSync(path + '/edu');
            /* getSync(key,defValue) */
            this.globalData.token = storage.getSync('token', 'noToken');
            console.info('APP Token :' + this.globalData.token);
        }).catch((error) => {
            console.error('Failed to obtain the file directory. Cause: ' + error.message);
        })
    },
    globalData: {
        "baseImageUrl": 'http://119.29.77.218:8080/edu-platform/background/image/',
        "path": '',
        "token": ''
    }

    /*,
    storagePath:{
        path : HttpUtil.getPath()
    }*/
}
